package com.singzi.testCase;

import org.junit.Test;

import javax.jws.soap.SOAPMessageHandlers;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;

public class arrayTest {
    @Test
    //返回数组的长度
    public void test01(){
        int []nums = {1,2,3,4,5,6};

        Integer []arr = new Integer[nums.length];
        for (int i = 0; i < nums.length; i++) {
            arr[i] = nums[i];
        }
        Arrays.sort(arr, (o1, o2) -> 0);
        System.out.println(nums.length);
    }
    @Test
    public void remainTest(){
        long  a = 407 *407;
        System.out.println(a % 1337);
    }
    @Test
    //数组越界
    public void indexTest(){
        int []a = new int[5];
        for (int i = 0; i < 10; i++) {
            if(i<5&&a[i]==0){
                System.out.println(i);
            }
        }
    }
    @Test
    public void arraySort(){
        int [][]a =  new int[][]{
                {1, 2},
                {2, 3},
                {0, 2}
        };
        Arrays.sort(a, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                if(o1[0]==o2[0]) return o1[1]-o2[1];
                return o1[0]-o2[0];
            }
        });
        System.out.println(Arrays.deepToString(a));

        Integer[] nums = new Integer[2];
        nums = new Integer[]{34, 234, 32423, 2342, 647, 77, 8, 1, 1};
//        int k1 = 0,k2 = 0;
        Arrays.sort(nums,(o1,o2)->{
            String s1 = String.valueOf(o1) + String.valueOf(o2);
            String s2 = String.valueOf(o2) + String.valueOf(o1);
            return s1.compareTo(s2);
        });
        System.out.println(Arrays.toString(nums));
    }
    @Test
    public void charPrint(){
        System.out.println((int) ('1' - '0'));
    }
    @Test
    public void ccc(){
        long a = 1;
        String s1 = new String("123");
        String s2 = new String("123");
        HashMap<String, Integer> map = new HashMap<>();
        map.put(s1, 2);
        System.out.println(map.get(s2));
        System.out.println(map.get("123"));


    }



}
